package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.CollectBean;
import com.lwj.liwanjia.impl.CollectView;
import com.lwj.liwanjia.model.CollectModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/27.
 */

public class CollectPresenter {
    private CollectModel collectModel;
    private CollectView collectView;

    public CollectPresenter(CollectView collectView) {
        this.collectView = collectView;
        collectModel = new CollectModel();
    }

    public void getCollect(String token, String commodityType, String commodityCode) {
        if (collectView != null) {
            collectModel.getCollect(token, commodityType, commodityCode, new Subscriber<CollectBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    collectView.showError((Exception) e);
                }

                @Override
                public void onNext(CollectBean collectBean) {
                    collectView.getCollect(collectBean);
                }
            });
        }
    }
}
